$(function () {
    //======================
    //======设置查询条件========
    //======================
    var selectData={"id":$("#zcfzb_detail_toolbar [name='id']").val(),"jc":$("#zcfzb_detail_toolbar [name='jc']").val()};
    //内部公司
    $("#zcfzb_detail_toolbar [name='gsId']").gsjgtree(1);
    //起始时间
    $("#zcfzb_detail_toolbar [name='dateStart']").datebox();
    $("#zcfzb_detail_toolbar [name='dateEnd']").datebox();
    $("#zcfzb_detail_toolbar [name='khId']").qyjgzcombobox({
        selectData:selectData
    });
    //搜索按钮
    $("#zcfzb_detail_toolbar [name='searchButton']").click(function () {
        if(!$("#zcfzb_detail_toolbar [name='khId']").val()) {
            $.messager.alert("提示","请选择客户！","info");
            return;
        }
        $(detailGrid).datagrid({
            queryParams: {
                khId: $("#zcfzb_detail_toolbar [name='khId']").val(),
                dateStart: $("#zcfzb_detail_toolbar [name='dateStart']").val(),
                endDate: $("#zcfzb_detail_toolbar [name='dateEnd']").val(),
                nbgsId: $("#zcfzb_detail_toolbar [name='nbgsId']").val()
            }});
    });


//======================
//========统计列表========
//======================
    var detailGrid = $("#zcfzb_detail_grid").datagrid({
        url: $.webPath() + '/report/zcfzb/zcfzbmxList',
        toolbar: "#zcfzb_detail_toolbar",
        rownumbers: true,
        pagination:true,
        singleSelect: true,
        showFooter:true,
        fit: true,
        fitColumns: true,
        queryParams: {
            type: $("#zcfzb_detail_toolbar [name='type']").val(),
            gsId: $("#zcfzb_detail_toolbar [name='gsId']").val(),
            zcfzbStartDate: $("#zcfzb_detail_toolbar [name='zcfzbStartDate']").val(),
            zcfzbEndDate: $("#zcfzb_detail_toolbar [name='zcfzbEndDate']").val()
        },
        columns: [
            [
                {field: 'kmmc', title: '科目名称', width: 100, align: 'center'},
                {field: 'dh', title: '单号', width: 100, align: 'center'},
                {field: 'sbgs_mc', title: '公司名称', width: 100, align: 'center'},
                {field: 'khmc', title: '客户名称', width: 100, align: 'center'},
                {field: 'lx', title: '单据类型', width: 100, align: 'center'},
                {field: 'jf', title: '借方', width: 100, align: 'center'},
                {field: 'df', title: '贷方', width: 100, align: 'center'},
                {field: 'drrq', title: '导入日期', width: 100, align: 'center'},
                {field: 'sbrmc', title: '申报人', width: 100, align: 'center'},
                {field: 'cjrq', title: '创建日期', width: 100, align: 'center'}
            ]
        ]
    });
});
